//
//  ListenTableViewCell.m
//  MountEverestFM
//
//  Created by ChenNing on 15/10/29.
//  Copyright © 2015年 chenn. All rights reserved.
//

#import "CommendBestListenTableViewCell.h"

@interface CommendBestListenTableViewCell()
// 曲目图
@property(nonatomic,strong)UIImageView *imageImageView;
// 标题
@property(nonatomic,strong)UILabel *titleLabel;
// 内容
@property(nonatomic,strong)UILabel *contentLabel;
// 专辑图标
@property(nonatomic,strong)UIImageView *specialImageView;
// 专辑数量
@property(nonatomic,strong)UILabel *specialLabel;
// 分割线
@property(nonatomic,strong)UIImageView *lineImageView;

@end

@implementation CommendBestListenTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imageImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_imageImageView];
        
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        
        self.contentLabel = [[UILabel alloc] init];
        self.contentLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_contentLabel];
        
        self.specialImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_specialImageView];
        
        self.specialLabel = [[UILabel alloc] init];
        self.specialLabel.font = [UIFont systemFontOfSize:15];
        self.specialLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_specialLabel];
        
        self.lineImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_lineImageView];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.imageImageView.frame = CGRectMake(FM_Screen_Pts_Width*10, FM_Screen_Pts_Height*10, FM_Screen_Pts_Width*80, FM_Screen_Pts_Width*80);
    
    self.titleLabel.frame = CGRectMake(FM_Screen_Pts_Width*100, FM_Screen_Pts_Height*10, FM_Screen_Width-FM_Screen_Pts_Width*110, FM_Screen_Pts_Width*30);

    self.contentLabel.frame = CGRectMake(FM_Screen_Pts_Width*100, FM_Screen_Pts_Height*10+FM_Screen_Pts_Width*30, FM_Screen_Width-FM_Screen_Pts_Width*110, FM_Screen_Pts_Width*30);
 
    self.specialImageView.frame = CGRectMake(FM_Screen_Pts_Width*100, FM_Screen_Pts_Height*10+FM_Screen_Pts_Width*60, FM_Screen_Pts_Width*20, FM_Screen_Pts_Width*20);
    self.specialLabel.frame = CGRectMake(FM_Screen_Pts_Width*125, FM_Screen_Pts_Height*10+FM_Screen_Pts_Width*60, FM_Screen_Pts_Width*150, FM_Screen_Pts_Width*20);
    
    self.lineImageView.frame = CGRectMake(FM_Screen_Pts_Width*100, FM_Screen_Pts_Width*80 + FM_Screen_Pts_Height*20, FM_Screen_Width-FM_Screen_Pts_Width*100, FM_Screen_Pts_Height*1);
}

- (void)setListenDic:(NSDictionary *)listenDic
{
    if (_listenDic != listenDic) {
        _listenDic = listenDic;
    }
    [self setListenInfo:listenDic];
}

- (void)setListenInfo:(NSDictionary *)listenDic
{
    if ([listenDic objectForKey:@"coverPath"]==nil) {
        
        [self.imageImageView sd_setImageWithURL:[NSURL URLWithString:[listenDic objectForKey:@"coverPathSmall"]] placeholderImage:[UIImage imageNamed:@"find_kind_btn_default@3x.png"]];
        self.titleLabel.text = [listenDic objectForKey:@"title"];
        self.contentLabel.text = [listenDic objectForKey:@"subtitle"];
        self.specialImageView.image = [UIImage imageNamed:@"find_specialicon@2x.png"];
        self.specialLabel.text = [listenDic objectForKey:@"footnote"];
        self.lineImageView.image = [UIImage imageNamed:@"line_horizeontal@2x.png"];


    }else{
    [self.imageImageView sd_setImageWithURL:[NSURL URLWithString:[listenDic objectForKey:@"coverPath"]] placeholderImage:[UIImage imageNamed:@"find_kind_btn_default@3x.png"]];
    self.titleLabel.text = [listenDic objectForKey:@"title"];
    self.contentLabel.text = [listenDic objectForKey:@"subtitle"];
    self.specialImageView.image = [UIImage imageNamed:@"find_specialicon@2x.png"];
    self.specialLabel.text = [listenDic objectForKey:@"footnote"];
    self.lineImageView.image = [UIImage imageNamed:@"line_horizeontal@2x.png"];
    }
}


@end
